//
//  Extension+UIBarButtonItem.swift
//  weibo
//
//  Created by 张城 on 16/7/19.
//  Copyright © 2016年 张城. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(title: String? = nil,imgName: String? = nil,target: AnyObject?,action: Selector) {
        self.init()
        
        let  button = UIButton()
        
        if let til = title {
            button.setTitle(til, forState: .Normal)
            button.setTitleColor(UIColor.orangeColor(), forState: .Normal)
            button.titleLabel?.font = UIFont.systemFontOfSize(15)
        }
        
        if let img = imgName {
            button.setImage(UIImage(named: img), forState: .Normal)
        }
        
        
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        button.sizeToFit()
        self.customView = button
        
    }
    
    
    
    
    
    
    
    
    
    
    
}